home *** CD-ROM | disk | FTP | other *** search
/ Total Web Page (Professional Suite) / Total Web Page 99.iso / CGI / DOWNLOAD.CGI-S=COOKIELIB&C=TXT&F=CCOUNTER.PL < prev    next >
Perl Script  |  1996-06-03  |  4KB  |  96 lines

  1. #!/usr/local/bin/perl
  2. ##############################################################################
  3. # Cookie Counter                Version 2.1                                  #
  4. # Copyright 1996 Matt Wright    mattw@worldwidemart.com                      #
  5. # Created 07/14/96              Last Modified 12/13/96                       #
  6. # Scripts Archive at:           http://www.worldwidemart.com/scripts/        #
  7. ##############################################################################
  8. # COPYRIGHT NOTICE                                                           #
  9. # Copyright 1996 Matthew M. Wright  All Rights Reserved.                     #
  10. #                                                                            #
  11. # Cookie Counter may be used and modified free of charge by anyone so long as#
  12. # this copyright notice and the comments above remain intact.  By using this #
  13. # code you agree to indemnify Matthew M. Wright from any liability that      #  
  14. # might arise from it's use.                                                 #  
  15. #                                                                            #
  16. # Selling the code for this program without prior written consent is         #
  17. # expressly forbidden.  In other words, please ask first before you try and  #
  18. # make money off of my program.                                              #
  19. #                                                                            #
  20. # Obtain permission before redistributing this software over the Internet or #
  21. # in any other medium.  In all cases copyright and header must remain intact #
  22. ##############################################################################
  23.  
  24. # Allow script to use the Cookie Subroutines.  You may need to change this   #
  25. # if cookie.lib is not in the same directory as this script.                 #
  26. # Cookie Counter version 2.1 is written for HTTP Cookie Library 2.1          #
  27.  
  28. require 'cookie.lib';
  29.  
  30. # If there already is a count cookie, proceed without setting a new one.     #
  31.  
  32. if (&GetCookies('count')) {
  33.  
  34.     # Increment the counter.                                                 #
  35.  
  36.     $Cookies{'count'}++;
  37.  
  38.     # Print out the HTML Content-Type header.                                #
  39.  
  40.     print "Content-type: text/html\n";
  41.  
  42.     # Set the updated cookie with new count.                                 #
  43.  
  44.     &SetCookies('count',$Cookies{'count'});
  45.  
  46.     # End the headers sent to browser.                                       #
  47.  
  48.     print "\n";
  49.  
  50.     # Print Top of HTML Page                                                 #
  51.  
  52.     print "<html>\n";
  53.     print " <head>\n";
  54.     print "<title>Example Cookie Counter</title>\n";
  55.     print " </head>\n";
  56.     print " <body bgcolor=#FFFFFF text=#000000>\n";
  57.     print "  <center><h1>Repeat Visitor!</h1>\n";
  58.  
  59.     # Print out how many times they have visited this script.                #
  60.  
  61.     print "You have been to this site $Cookies{'count'} times!<p>\n"; 
  62.  
  63.     # Print out the end of the HTML page.
  64.     print "(This only works on Cookie-Capable Browsers)\n";
  65.     print "<p><a href=\"http://www.worldwidemart.com/scripts/cookielib.shtml\">";
  66.     print "Matt's Script Archive: HTTP Cookie Library</a>\n";
  67.     print "</body></html>";
  68. }
  69.  
  70. # Otherwise, if the use didn't already have a cookie, let's give them one!   #
  71. else {
  72.  
  73.     # Print out the HTML Content-Type header.                                #
  74.     print "Content-type: text/html\n";
  75.  
  76.     # Set a new cookie.                                                      #
  77.     &SetCookies('count','1');
  78.  
  79.     # End the headers sent to browser.                                       #
  80.     print "\n";
  81.  
  82.     # Print HTML Page                                                        #
  83.     print "<html>\n";
  84.     print " <head>\n";
  85.     print "  <title>Example Cookie Counter</title>\n";
  86.     print " </head>\n";
  87.     print " <body bgcolor=#FFFFFF text=#000000>\n";
  88.     print "  <center><h1>First Time, eh?</h1>\n";
  89.     print "I can see this is your first time to load this page.\n";
  90.     print "Reload to become a repeat visitor!<p>\n";
  91.     print "(This only works on Cookie-Capable Browsers)\n";
  92.     print "<p><a href=\"http://www.worldwidemart.com/scripts/cookielib.shtml\">";
  93.     print "Matt's Script Archive: HTTP Cookie Library</a>\n";
  94.     print "</body></html>\n";
  95. }
  96.